package com.example.chapter11;

import java.util.concurrent.TimeUnit;

public class Demo01 {

    public volatile static boolean exit = false;

    public static class T extends Thread{
        @Override
        public void run() {
            while (true){
                if (exit){
                    break;
                }
            }
        }
    }

    public static void isExit(){
        exit = true;
    }

    public static void main(String[] args) throws InterruptedException {
        T t = new T();
        t.start();
        TimeUnit.SECONDS.sleep(10);
        isExit();
    }
}
